package losrebellos.lospistoleros.core.dispatcher 
{
	import losrebellos.events.EventDispatcherPlus;

	import flash.errors.IllegalOperationError;

	/*
	 *
	 * @author los rebellos - ben@benoitvinay.com
	 *
	 */
	public class GlobalEventDispatcher extends EventDispatcherPlus 
	{
		/*
		 *
		 * CONSTRUCTOR
		 * nothing but a global event dispatcher, for PAccessor only (controller, command)
		 *
		 */
		public function GlobalEventDispatcher(singleton:SingletonEnforcer)
		{
			super();
			
			if(!singleton)
			{
				throw new IllegalOperationError(">>>>> GlobalEventDispatcher class is a singleton");
			}
		}

		
		/*
		 * 
		 * SINGLETON
		 * 
		 */
		private static var _instance:GlobalEventDispatcher = null;
		public static function get instance():GlobalEventDispatcher
		{
			if(!_instance)
				_instance = new GlobalEventDispatcher(new SingletonEnforcer);
			
			return _instance;
		}
	}
}
class SingletonEnforcer {}